package com.soxing.braindata.common.util;

import org.springframework.util.DigestUtils;

public class MD5Util {
	// 盐，用于混交md5
	private static final String SLAT = "&%51233***&&%%$$#@";

	/**
	 * 生成md5
	 * 
	 * @param str
	 * @return
	 */
	public static String getMD5(String str) {
		String base = str;
		String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
		return md5;
	}

	/**
	 * 生成md5
	 * 
	 * @param str
	 * @return
	 */
	public static String getMD5ForSlat(String str, String slat) {
		String base = str + "/" + slat;
		String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
		return md5;
	}

	/**
	 * 生成md5
	 * 
	 * @param str
	 * @return
	 */
	public static String getMD5ForDefaultSlat(String str) {
		String base = str + "/" + SLAT;
		String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
		return md5;
	}

	public static void main(String[] args) {
		String a = getMD5("123456");
		System.out.println(a);
	}
}
